<?php include $this->header();?>
<?php if(false) {?>
<link rel="stylesheet" rev="stylesheet" href="../../../images/admincp/style.css" type="text/css" media="all" />
<?php }?>
<a href="<?=UE_Url::make('system/category/add')?>" class="btn-r-top">添加栏目</a>
<form method="post">
  <div class="p1 mt bd bg">
      <table class="list rank" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr class="th">
          <td align="center" width="50">排序</td>
          <td align="center" width="40">ID</td>
          <td align="left">名称</td>
          <td align="center" width="120">地址</td>
          <td align="center" width="72">导航栏显示</td>
          <td align="center" width="40">启用</td>
          <td width="210" align="center">管理操作</td>
        </tr>
        <?php foreach ($_cats as $_cat) {?>
        <tr class="bb">
          <td align="center"><input type="text" name="cat_order[<?=$_cat['cat_id']?>]" value="<?=$_cat['cat_order']?>" size="3" style="text-align:center;"></td>
          <td align="center"><?=$_cat['cat_id']?></td>
          <td align="left"><?=$_cat['icon']?><?=$_cat['cat_name']?></td>
          <td align="center"><a href="<?=$_cat['cat_url']?>" target="_blank">查看页面/获取地址</a></td>
          <td align="center" id="cat_nav_show_<?=$_cat['cat_id']?>" class="cat_nav_show" onclick="chNavShow(<?=$_cat['cat_id']?>);" style="cursor:pointer"><?php if($_cat['cat_nav_show']) {?><span class="green">是</span><?php } else { ?><span class="red">否</span><?php }?></td>
          <td align="center" id="cat_enabled_<?=$_cat['cat_id']?>" class="cat_enabled" onclick="chEnabled(<?=$_cat['cat_id']?>);" style="cursor:pointer"><?php if($_cat['cat_enabled']) {?><span class="green">是</span><?php } else { ?><span class="red">否</span><?php }?></td>
          <td align="center"><a href="<?=UE_Url::make($_cat['cat_app'].'/admin/list/all/cat_id/'.$_cat['cat_id'])?>">管理内容</a> | <a href="<?=UE_Url::make('system/category/add/subcat/cat_parent_id/'.$_cat['cat_id'].'/app_id/'.$_cat['cat_app'])?>">添加子分类</a> | <a href="<?=UE_Url::make('system/category/edit/'.$_cat['cat_id'])?>">编辑</a> | <a href="<?=UE_Url::make('system/category/del/'.$_cat['cat_id'])?>" onclick="return confirm('您确定要删除该分类吗？一旦删除将不可恢复。')">删除</a></td>
        </tr>  	
        <?php }?>
      </table>
      <p style="padding:6px 10px;"><input type="submit" value="排序" class="btn"></p>
  </div>
</form>
<script type="text/javascript">
//<![CDATA[
function chNavShow(cid) {
	var url = '<?=UE_Url::make("system/category/ajaxChInNav/")?>&id='+cid;
    $.getJSON(url, function(json){
		if(json.err) {
			alert(json.err);
		} else {
			if(json.r == 1) {
				$('#cat_nav_show_'+cid).html('<span class="green">是</span>');
			} else {
			    $('#cat_nav_show_'+cid).html('<span class="red">否</span>');
			}
		}
    });
}

function chEnabled(cid) {
	var url = '<?=UE_Url::make("system/category/ajaxChEnabled/")?>&id='+cid;
    $.getJSON(url, function(json){
		if(json.err) {
			alert(json.err);
		} else {
			if(json.r == 1) {
				$('#cat_enabled_'+cid).html('<span class="green">是</span>');
			} else {
			    $('#cat_enabled_'+cid).html('<span class="red">否</span>');
			}
		}
    });
}
//]]>
</script>
<?php include $this->footer();?>